package ab.mes.service.impl;

import ab.mes.entity.Bin;
import ab.mes.entity.Working;
import ab.mes.mapper.WorkingMapper;
import ab.mes.service.WorkingService;
import ab.mes.tools.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WorkingServiceImpl implements WorkingService {

    @Autowired
    private WorkingMapper workingMapper;

    //查询所有工序名称和图片
    public Result selectWorking1(){
        Result result = new Result();
        result.getMap().put("working",workingMapper.selectWorking1());
        return result;
    }
    //根据工序名称查询所有名称和图片
    public Result selectByName(String process_name){
        Result result = new Result();
        result.getMap().put("working",workingMapper.selectByName(process_name));
        return result;
    }
    //切换是否打印状态
    public Result updatePrintByName(String process_name){
        Result result = new Result();
        Boolean state;
        state = workingMapper.selectById(process_name).getOutputToPrint();
        state = !state;
        result.getMap().put("working",workingMapper.updatePrintByName(process_name,state));
        return result;
    }
    //切换是否首件检查状态
    public Result updateCheckByName(String process_name){
        Result result = new Result();
        Boolean state;
        state = workingMapper.selectById(process_name).getFirstPieceOutputLimit();
        state = !state;
        result.getMap().put("working",workingMapper.updateCheckByName(process_name,state));
        return result;
    }
}
